package org.example.generator;

import freemarker.template.TemplateException;
import org.example.model.MainTemplateConfig;

import java.io.File;
import java.io.IOException;

/**
 * 动静结合代码生成
 * @author ricejson
 */
public class MainGenerator {
    public static void doGenerate(MainTemplateConfig config) throws TemplateException, IOException {
        String projectPath = System.getProperty("user.dir");
        String inputPath = new File(projectPath).getParent() + File.separator + "rice-generator-demo-projects" +
                File.separator + "acm-template";
        String outputPath = new File(projectPath).getParent();
        StaticGenerator.doGenerate(inputPath, outputPath);
        String templateRootPath = projectPath + File.separator +
                "src/main/resources/templates"; // 模板根路径
        String destPath = outputPath + File.separator +
                "acm-template/src/com/yupi/acm/MainTemplate.java"; // 目标路径
        // 动态代码生成
        DynamicGenerator.deGenerator(templateRootPath, destPath, config);
    }
}
